package st.business.tepth.business.user.busnumber.workholder.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

import st.business.tepth.R;
import st.business.tepth.base.OnItemChooseListener;
import st.business.tepth.business.bean.ProgramBean;
import st.shadow.library.ui.recycler.MultipleItemEntity;

/**
 * @author zhangyu
 * @date 2019/2/21
 */
public class DialogDeleteProgram extends Dialog {
    public DialogDeleteProgram(Context context,
                               ProgramBean diagnoseBean,
                               final OnItemChooseListener<Object> listener) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = LayoutInflater.from(context).
                inflate(R.layout.dialog_delete_program, null);
        view.findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
        recyclerView.setAdapter(new BaseQuickAdapter<MultipleItemEntity, BaseViewHolder>
                (R.layout.item_goods_delete, diagnoseToEntity(diagnoseBean)) {
            @Override
            protected void convert(BaseViewHolder helper, MultipleItemEntity item) {
                helper.setText(R.id.tv_part_name, (CharSequence) item.getField("name"));
                helper.setText(R.id.tv_part_type, (CharSequence) item.getField("code"));
                helper.setText(R.id.tv_brand, (CharSequence) item.getField("brand"));
                helper.setText(R.id.tv_version, (CharSequence) item.getField("version"));
                helper.setText(R.id.tv_specification, (CharSequence) item.getField("specification"));
                helper.setText(R.id.tv_batch, (CharSequence) item.getField("batch"));
                helper.setText(R.id.tv_check_state, (CharSequence) item.getField("count"));
            }
        });
        view.findViewById(R.id.tv_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onChoose(null);
                }
                dismiss();
            }
        });
        setContentView(view);
    }

    private List<MultipleItemEntity> diagnoseToEntity(ProgramBean diagnoseBean) {
        List<MultipleItemEntity> list = new ArrayList<>();

        return list;
    }
}
